<?php

class Fb extends Controller {
	
	function Fb()
	{
		parent::Controller();
		
		$this->load->scaffolding('feed');
	}
	
	function index()
	{
		$data["title"] = "Pacuanpantun";
		$data["content"] = "blah blah";
		$data["fruits"] = array("apple", "cherry", "melon");
		
		//$this->load->vars($data);
		$this->load->view('fb_view', $data);
	}
	
	function facebook()
	{
		$adata = array();
		
		$this->load->library('myutils');
		
		$data["title"] = "FB wall";
		$data["content"] = "Our Facebook Wall";
		//$rs = $this->db->get('feed');
		$rs = $this->db->query('SELECT * FROM feed LIMIT 0,5');
		
		foreach ($rs->result() as $row){
			if ($row->created_time > 0)
				$row->created_time = $this->myutils->ago($row->created_time);
			else
				$row->created_time = "";
			$adata[] = $row;
		}
		 
		$data["feeds"] = $adata;
		
		$config['base_url'] = 'http://myfacebook.com/index.php/fb/facebook/';
		$config['total_rows'] = '50';
		$config['per_page'] = '5';

		$this->load->library('pagination');
		$this->pagination->initialize($config); 
		
		$data["paging"] = $this->pagination->create_links();
		
		$this->load->view('facebook_view', $data);
	}
	
	function twitter()
	{
	
	}
}